package com.l024.loanthief.entity;

import androidx.annotation.Nullable;

import com.l024.loanthief.R;

import java.io.Serializable;

/**
 * @author wu_ming_zhi_bei
 * @date 2021/1/18 22:17
 * @Notes
 */
public class DeviceEntity implements Serializable {
    private int id;
    private String ip;
    private String phoneName;
    private int imgId;

    public DeviceEntity() {
        this.imgId = R.mipmap.ic_launcher;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getPhoneName() {
        return phoneName;
    }

    public void setPhoneName(String phoneName) {
        this.phoneName = phoneName;
    }

    public int getImgId() {
        return imgId;
    }

    public void setImgId(int imgId) {
        this.imgId = imgId;
    }

    @Override
    public String toString() {
        return "DeviceEntity{" +
                "id=" + id +
                ", ip='" + ip + '\'' +
                ", phoneName='" + phoneName + '\'' +
                ", imgId=" + imgId +
                '}';
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if(this == obj){
            return true;//地址相等
        }
        if(obj == null){
            return false;//非空性：对于任意非空引用x，x.equals(null)应该返回false。
        }
        if(obj instanceof DeviceEntity){
            DeviceEntity other = (DeviceEntity) obj;
            //需要比较的字段相等，则这两个对象相等
            if(this.ip.equals(other.ip)){
                return true;
            }
        }
        return false;
    }



    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + (ip == null ? 0 : ip.hashCode());
        return result;
    }
}
